/*********************************************************
          File Name:16.56.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 07 May 2016 12:21:25 PM CST
**********************************************************/

#include <iostream>
#include <sstream>

template<typename T>
std::string p(T&& x)
{
  std::ostringstream os;
  os<< x << " ";
  return os.str();
}

template<typename T>
std::ostream& Errmsg(std::ostream& os, T&& arg)
{
  os << arg;
  return os;
}

template<typename T, typename... Args>
std::ostream& Errmsg(std::ostream& os, T&& arg, Args&&... args)
{
  os << p(arg);
  return Errmsg(os, p(args)...);
}

int main()
{
  int i = 309;
  std::string s{"string"};
  Errmsg(std::cout, 1, i, s, "test\n");
}
